#pragma once

#include <QObject>
#include <QString>
#include <pulse/pulseaudio.h>

struct PulseDevice {
    int id;
    QString name;
    pa_cvolume vol;
    int level;
};

class PulseClient : public QObject {
    Q_OBJECT
public:
    PulseClient();

    void setSpeakerVolume(QString name, int vol);
    void setInputVolume(QString name, int vol);

    void setDefaultSpeaker(QString name);
    void setDefaultMicphone(QString name);

    // paplay + parecord
    void startPlayBack();
    void stopPlayBack();
    void startRecord();
    void stopRecord();

signals:
    void subEvent(int add_remove_change, int sink_source_volume);

private:
    static void contextCallBack(pa_context*, void*);

private:
    pa_mainloop* m_loop;
    pa_mainloop_api* m_api;
    pa_context* m_ctx;
};
